import axios from 'axios'
import qs from 'qs'
// import { Message } from 'iview'
export const baseURL = 'http://192.168.200.131:8080';
// export const baseURL = 'http://192.168.200.158:8080/';

export const http = axios.create({
    baseURL: baseURL,
    withCredentials: true,
    transformRequest: [function (data) {
        return qs.stringify(data);
    }]
});

http.interceptors.response.use(function (res) {
    handlerError(res.data)
    return res;
});

export const handlerError = ({ code, msg }) => {
    if (code == -2) {
        window.location.href = '#/index';
    }
    if (code != 0) {
        // Message.info(msg);
    }
};